
// EntityCheckList is deprecated!

function WebEntityCheckList(id)
{
    this.superClase = CheckList;
    this.superClase(id);
          
    this.entityName = "";
    this.orderBy = "";
    this.foreingProperty = "";    
    this.initValue = "";      

    this.loadingString = "Loading...";
    
	this.Clone = EntityCheckList_Clone;
	
	this.Fill = EntityCheckList_Fill;
	this.BeginLoading = EntityCheckList_BeginLoading;
	this.EndLoading = EntityCheckList_EndLoading;
	this.RefreshData = EntityCheckList_RefreshData; // deprecated
	this.RefreshDataSinc = EntityCheckList_RefreshDataSinc;
}

function EntityCheckList_Clone(newId)
{
    var newCheckList = new WebEntityCheckList(newId);

	//Atributos Publicos
	newCheckList.width = this.width;
	newCheckList.size = this.size;
	newCheckList.bgSelect = this.bgSelect;
	newCheckList.allowOnlySelecteds = this.allowOnlySelecteds;
	newCheckList.onlySelecteds = this.onlySelecteds;
	newCheckList.onlySelectedsLabel = this.onlySelectedsLabel;
	newCheckList.fullElementCheck = this.fullElementCheck;
	newCheckList.pathImages = this.pathImages;
	
    for(var i=0; i<this.items.length; i++)
        newCheckList.items.push(this.items[i].slice());

    newCheckList.itemsShow = this.itemsShow.slice();
	newCheckList.count = this.count;	
	newCheckList.enabled = this.enabled;
	
    newCheckList.entityName = this.entityName;
    newCheckList.orderBy = this.orderBy;
    newCheckList.foreingProperty = this.foreingProperty;
    		
	newCheckList.ClearSelection();
	    		
	return newCheckList;
}

function EntityCheckList_Fill(items)
{
    if(!Common.isArray(items))    
        return -1;
        
    this.redraw = false;  
    this.ClearList();

    var keyvalue;
    for(var i=0; i<items.length; i++)
    {
        keyvalue = items[i].split("|");
        this.AddItem(keyvalue[0], keyvalue[1]);
    }
    
    this.redraw = true;  
    this.Refresh();
}

function EntityCheckList_BeginLoading()
{
    // Not Implemented
}

function EntityCheckList_EndLoading()
{
    // Not Implemented
}

function EntityCheckList_RefreshData(parentValue)
{
    var property = this.foreingProperty;
    var orderBy = this.orderBy;
    
    if(!parentValue)  
        parentValue = "";
        
    // llamado Ajax para refrescar la lista 
    this.BeginLoading();      	
    EntityCheckList.GetList(this.entityName, property, parentValue, orderBy, EntityCheckList_GetListCallBack, this.id);
}

function EntityCheckList_RefreshDataSinc(parentValue)
{
    var property = this.foreingProperty;
    var orderBy = this.orderBy;
    
    if(!parentValue)
        parentValue = "";
        
    // llamado Ajax para refrescar la lista 
    this.BeginLoading();      	
    
    var response = EntityCheckList.GetList(this.entityName, property, parentValue, orderBy);
    response.context = this.id;
    EntityCheckList_GetListCallBack(response);
}

function EntityCheckList_RegisterRelationship(idparent, idchild)
{
    Entity_Relationships[idparent] = idchild;
}

function EntityCheckList_GetListCallBack(response)
{
    var listId = response.context;
    var mlist = CheckList_Instances[listId];

    if ( (response.error) && (typeof(response.error) != "xml") ) {
        alert(response.error);
    }
    else {
        var items = response.value;
        if (items) 
            mlist.Fill(items);
            
	    eval(this.onChange);	
    }    

    mlist.EndLoading();    
}    
